function ajax(url) {
  return new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", url);
    xhr.responseType = "json";
    xhr.onload = function () {
      if (this.status === 200) {
        resolve(this.response);
      } else {
        reject(this.statusText);
      }
    };
    xhr.send();
  });
}

function* main() {
  const user = yield ajax("./api/users.json");
  console.log(user, "main user.json");

  const post = yield ajax("./api/posts.json");
  console.log(post, "main post.json");
}

const g = main();
const result = g.next();

result.value.then((data) => {
  const result2 = g.next(data);
  if (result2.done) return;

  result2.value.then((data) => {
    const result3 = g.next(data);
  });
});
